package com.gri.saas;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gri.utils.GriUtils;

/**
 * Servlet implementation class ProjectDetail
 */
public class ProjectDetail extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ProjectDetail() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request,response);
	}

	private void processRequest(HttpServletRequest request,
			HttpServletResponse response) {
		String projectId = request.getParameter("proId");
		if(projectId == null && projectId.isEmpty()){
			String message = "Project id is null";
			request.getSession().setAttribute("proDetailMessage", message);
			GriUtils.forwardToPage(request, response, "error.jsp");
		} else {
			String message = "Project id is " + projectId;
			request.getSession().setAttribute("proDetailMessage", message);
		}
		
	}

}
